<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      list-style: none;
    }

    nav {
      margin: 50px;
      width: 200px;
      background-color: #bfbfbf;
    }

    .item:hover>a {
      background-color: #999999;
    }

    .item>a {
      display: block;
      padding: 8px 10px;
      font-size: 18px;
      font-weight: bold;
      color: black;
      text-decoration: none;
    }

    .submenu {
      height: 0;
      transition: all 0.5s;
      overflow: hidden;
    }

    .item:hover .submenu {
      height: 84px;
    }

    .subitem {
      padding: 3px 15px;
      border-bottom: 1px dashed #fff;
    }

    .subitem>a {
      text-decoration: none;
      color: black;
    }
  </style>
</head>

<body>
  <nav>
    <ul class="menu">
      <li class="item">
        <a href="#897eq">主菜单1</a>
        <ul class="submenu">
          <li class="subitem"><a href="#897eq">子菜单1</a></li>
          <li class="subitem"><a href="#897eq">子菜单2</a></li>
          <li class="subitem"><a href="#897eq">子菜单3</a></li>
        </ul>
      </li>
      <li class="item">
        <a href="#897eq">主菜单2</a>
        <ul class="submenu">
          <li class="subitem"><a href="#897eq">子菜单1</a></li>
          <li class="subitem"><a href="#897eq">子菜单2</a></li>
          <li class="subitem"><a href="#897eq">子菜单3</a></li>
        </ul>
      </li>
      <li class="item">
        <a href="#897eq">主菜单3</a>
        <ul class="submenu">
          <li class="subitem"><a href="#897eq">子菜单1</a></li>
          <li class="subitem"><a href="#897eq">子菜单2</a></li>
          <li class="subitem"><a href="#897eq">子菜单3</a></li>
        </ul>
      </li>
      <li class="item">
        <a href="#897eq">主菜单4</a>
        <ul class="submenu">
          <li class="subitem"><a href="#897eq">子菜单1</a></li>
          <li class="subitem"><a href="#897eq">子菜单2</a></li>
          <li class="subitem"><a href="#897eq">子菜单3</a></li>
        </ul>
      </li>
      <li class="item">
        <a href="#897eq">主菜单5</a>
        <ul class="submenu">
          <li class="subitem"><a href="#897eq">子菜单1</a></li>
          <li class="subitem"><a href="#897eq">子菜单2</a></li>
          <li class="subitem"><a href="#897eq">子菜单3</a></li>
        </ul>
      </li>
    </ul>
  </nav>
</body>

</html>